\documentclass{beamer}
\usetheme{Copenhagen}
\usecolortheme[named=blue]{structure}
\begin{document}

\author{Dennis Castleberry, Arnab Ganguly, Sahar Navaz, Mohammad Tohid, Manohar Karki}
\title{Automated Classification of Sleep Stages using EEG/EOG and R\&K Rules}
\date{\today}

\maketitle

\section{Problem and Background}
\frame{\frametitle{Problem Definition}
  \begin{itemize} 
    \item The problem is to use electroencaphalogram data
          to create an automated sleep scorer.  Until
          recently, sleep psychologists have scored sleep
          stages by hand--a laborious and time-consuming
          task.
    \item Sleep stage scoring is a classification problem.
          We chose to create two classifiers: a rule-based
          classifier and a Naive Bayes classifier. 
  \end{itemize}
}

\frame{\frametitle{Background: Rechtschafffen \& Kales}
  \begin{itemize} 
    \item A standardized set of rules for manually scoring
          EEG data was developed by Rechtschaffen \& Kales.  
          The EEG data is divided into 30-second intervals
          called \textbf{epochs} and independently scored
          using the rule set.
    \item The resulting graph of the stages is called a
          \textbf{hypnogram}.
  \end{itemize}
}

\frame{\frametitle{}
  \includegraphics[width=\textwidth]{fig/eeg.png}
}

\frame{\frametitle{}
  \includegraphics[width=\textwidth]{fig/hypnogram.png}
}

\frame{\frametitle{Background: EEG}
  \begin{itemize} 
    \item Electroencephalogram (EEG) is a measure of electrical
          activity along the scalp.
    \item Certain waveforms manifest in the EEG output during
          different stages of consciousness.  For example, a
          wave called a K-complex appears predominantly in Stage 
          2 sleep. Also, amplitude and frequency vary among
          the sleep stages.
  \end{itemize}
}

\frame{\frametitle{}
  \begin{center}
  \includegraphics[width=.7\textwidth]{fig/eeg-map.png}
  \end{center}
}

\frame{\frametitle{}
  \includegraphics[width=\textwidth]{fig/spindle.png}
}

\frame{\frametitle{}
  \includegraphics[width=\textwidth]{fig/kcomplexes.png}
}

\frame{\frametitle{Background: The R\&K Rules}
  \begin{itemize} 
    \item (W): there is a low voltage within the $10-30 \mu V$
          range and mixed frequency.
    \item (1): low-voltage mixed-frequency EEG with highest
          amplitude in the $2-7 \mu V$ range.
    \item (2): presence of sleep spindles and K-complexes at
          least three minutes apart
    \item (3): 20-50\% of the record should contain waves
          with $2 Hz$ or lower and with amplitudes above
          $75 \mu V$.
    \item (4): similar to (3), except amplitudes greater
          than $75 \mu V$ appear in 50\% of the record.
    \item (R): similar to (W), except that the EOG activity
          is high.
    \item (MT): if the EEG signals are unclear due to
          amplifier blocking or muscle activity.
  \end{itemize}
}

\frame{\frametitle{}
  \includegraphics[width=\textwidth]{fig/stages.png}
}

\frame{\frametitle{Background: Waveforms}
  \begin{itemize} 
   \item There are two waveforms of concern for the Stage 2
         classification:
   \begin{itemize} 
     \item \textbf{Sleep spindles} have a duration
           of at least $.5 s$ with frequencies in the $12-14 Hz$
           range. 
     \item \textbf{K-complexes} are sharp negative spikes followed
           by slow positive peaks, at least $.5 s$ in duration,
           usually with higher amplitude than the surrounding
           waves.
   \end{itemize} 
   \item We noted that, although the Rechtschaffen \& Kales rules
         are clearly-defined, the sleep spindles and K-complexes 
         are less so. Their interpretation is often 
         subjective and based upon contextual information, which
         is problematic for manual scoring.
  \end{itemize}
}

\section{Hypothesis}
\frame{\frametitle{Objective}
   \begin{itemize} 
     \item Bearing this in mind, our objective was to compare
           a direct rule-based automated scorer with a Naive
           Bayes classifier to see the extent to which the
           Naive Bayes classifier would compensate for measurement
           errors.
     \item For this, we would need to compute the attribute
           values ourselves, as well as devise an automated
           scorer faithful to the R\&K rules.
   \end{itemize} 
}

\frame{\frametitle{Hypothesis}
   \begin{itemize} 
     \item Suppose a rule-based classifier uses a set of
           attributes $A$. 
     \item We hypothesized that a Naive Bayes classifier using
           the a subset of $A$ would outperform our
           direct rule-based classifier.
     \item Our hypothesis was based upon the assumption that
           our waveform detection algorithms would yield a
           low accuracy. 
     \item The corresponding stages would not be detected 
           using a direct rule classifier where the waveform 
           detectors fail; however, since the Naive Bayes
           classifier uses all the attributes $A$ to profile 
           the stage, it may compensate for the waveform 
           detection errors.
   \end{itemize} 
}

\frame{ \frametitle{Data}
   \begin{itemize}
     \item We retrieved data from the Sleep-EDF database,
           available on-line at: 
           http://www.physionet.org/physiobank/database/sleep-edf/
     \item Each EEG recording has the following data:
      \begin{enumerate}
        \item Time stamp
        \item Fpz-Cz EEG
        \item Pz-Oz EEG
        \item EOG (electrooculogram)
      \end{enumerate} 
   \end{itemize} 
}

\section{Method}
\frame{\frametitle{Method: Extracting the Attributes}
  \begin{itemize}
    \item Using the rule set, we derived several attributes
          to evaluate per-epoch to be used with a Naive
          Bayes classifier:
    \begin{itemize}
      \item absolute value of the average of the amplitude
      \item sums of amplitudes of frequency ranges
      \item number of sleep spindle(s) detected
      \item number of K-complexes detected
    \end{itemize}
    With the per-epoch values for these attributes, a manual
    scorer can follow the R\&K rules to assign a stage to the
    epoch.
  \end{itemize}
}

\frame{\frametitle{Method: Calculating the Attributes}
  \begin{itemize}
    \item We used a straightforward approach for calculating
          the average amplitudes per epoch. 
    \item For the frequency items, we used a Fast Fourier
          Transform (FFT) on the epoch, then integrated over
          certain frequency ranges referred to in the R\&K
          rule set:
      \begin{enumerate}
        \item $0-2 Hz$
        \item $2-7 Hz$
        \item $7-12 Hz$
        \item $12-14 Hz$
      \end{enumerate} 
    \item This yields an uneven ``histogram'' giving the
          sums of the amplitudes for those frequency ranges.
    \item Since each sleep stage has a unique frequency and
          amplitude signature, we would expect these values
          to adequately characterize the epoch.
   \end{itemize}
}

\frame{\frametitle{Method: Sleep Spindles}
  \begin{itemize}
    \item The method for detecting sleep spindles is as follows:
     \begin{enumerate}
       \item A bypass filter is run for the frequency range between
             $12-14 Hz$.  This isolates the amplitudes of the wave
             which fall within that frequency range. 
       \item For each decisecond, the root mean squared is computed.
       \item If the root mean square is greater than an experimentally
             pre-determined threshold (in this case, 10) for five
             deciseconds ($.5 s$), then the waveform is labelled
             as a sleep spindle.
     \end{enumerate} 
    \item Our sleep spindle detector achieved a plateau accuracy of 
          $64\%$.
   \end{itemize}
}

\frame{\frametitle{Method: K-Complexes}
  \begin{itemize}
    \item For the K-complex detection, we first extracted sets of
          five values: $t_{start}, t_{max}, t_{mid}, t_{min}, t_{end}$.
    \item We then pruned this set using restrictions given from the 
          K-complex definition and the R\&K rules:
      \begin{itemize} 
        \item $t_{min}-t_{mid} > t_{mid}-t_{max}$
        \item $t_{end}-t_{start} > .5s$
      \end{itemize} 
    \item We also made generalizing assumptions for small fluctuations
          in the recording within an epoch:
      \begin{itemize} 
        \item $\frac{|A_{max}-M| + |M-A_{min}|}{2} > 
               \frac{\sum_i^N |A_i|}{N}$
      \end{itemize} 
    \item We adjusted the thresholds experimentally in order to 
          achieve a plateau accuracy of $54\%$.
   \end{itemize}
}

\frame{\frametitle{Method: Rule-Based Classifier \#1}
  \begin{itemize} 
    \item To provide a basis of comparison against our Naive
          Bayes classifier,
          we created a direct rule-based classifier based on 
          a direct translation of the Rechtschaffen \& Kales
          rules using our attribute values. 
    \item Our first rule-based classifier was loyal to the
          R\&K rules, using all the attributes called for in
          the stage classification.
    \item Our first classifier achieved an accuracy of $64\%$.
  \end{itemize} 
}

\frame{\frametitle{Method: Rule-Based Classifier \#2}
  \begin{itemize} 
    \item Our second rule-based classifier attempted to circumvent
          the requirement for a ``representative frequency'' 
          for the epoch.
    \item It mainly relied upon the detection of sleep spindles
          to distinguish between Stage 2 and Stage 3 sleep,
          and mean amplitude for the other stages. 
    \item Our second classifier achieved an accuracy of $66\%$.
  \end{itemize} 
}

\frame{\frametitle{Method: Naive Bayes Classifier}
  \begin{itemize} 
    \item Initially, we used a Naive Bayes classifier with
          20 attributes: mean, max, frequency histogram,
          number of  sleep spindles, number of K-complexes.  These attributes
          were computed for both EEG recordings, and mean
          was computed for EOG to provide training data
          to classify REM stages.
    \item Since the calculation of the attributes was time-
          consuming, we split an EEG record in half to use for
          our training and validation sets.
    \item However, this initial classifier produced an accuracy 
          of 6\%. After examining the correlation matrix for the 20
          attributes, we determined that this set of attributes
          violated the Naive Bayes assumption (they were not
          probabilistically independent). Thus, we pruned the
          attributes based values from the correlation matrix.
  \end{itemize} 
}

\frame{\frametitle{Method: Naive Bayes Classifier}
  \begin{itemize} 
    \item Experimentally, we tuned the attribute set until we
          achieved a plateau accuracy of 73\% using the
          frequency histogram.
    \item This accuracy outdoes the direct rule classifiers
          and, given the efficiency of computing the 
          amplitude-frequency integrals, is competitive with
          existing classifiers (which have accuracy ranges
          from 70-80\%)!
  \end{itemize} 
}

\section{Results and Conclusion}
\frame{\frametitle{Results}
  \begin{itemize} 
    \item The following table summarizes the accuracies of
          our measures and classifiers:
  \end{itemize} 
   \begin{center}
   \begin{tabular}{lc}
     Spindles               & 64\% \\ 
     K-complexes            & 54\% \\ 
     Rule Classifier   1    & 64\% \\ 
     Rule Classifier   2    & 66\% \\ 
     \textbf{Naive Bayes Classifier} & 73\% \\ 
   \end{tabular}
   \end{center}
}

\frame{\frametitle{Conclusion}
  \begin{itemize} 
    \item During our exploratory analysis of direct-rule
          and Naive Bayesian classifiers, we found that
          Naive Bayes classifiers can in fact compensate
          for measurement errors of attributes used in
          direct-rule classifiers.
    \item In addition, the accuracy of our Naive Bayes
          classifier has interesting implications for
          the R\&K rules; namely, the amplitude-frequency
          integrals seem to contain sufficient information
          to classify the epochs without using many of
          the other attributes referenced in the rule
          set. 
  \end{itemize} 
}

\frame{ \frametitle{References}
  \begin{itemize}
    \item Susmakova, Kristina. ``Human sleep and sleep EEG.'' Measurement Science Review 4.2 (2004): 59-74.
    \item Devuyst S., Dutoit T., Stenuit P., and Kerkhofs M. ``Automatic K-complexes detection in sleep 
          EEG recordings using likelihood thresholds.'' IEEE Engineering in Medicine and Biology Society (2010).
    \item Steffen Gais, Matthias Molle, Kay Helms, and Jan Born.
          ``Learning-dependent increases in sleep spindle activity.'' The Journal of Neuroscience 22.15 (2002).
  \end{itemize} 
}

\end{document}
